home *** CD-ROM | disk | FTP | other *** search
/ Hackers Handbook - Millenium Edition / Hackers Handbook.iso / library / hack99 / tetrix_1_13_16_bof.txt < prev    next >
Encoding:
Internet Message Format  |  1999-03-24  |  2.8 KB

  1. Date: Wed, 17 Feb 1999 13:03:45 -0800
  2. From: Steven Hodges <nsn@RAW.VELOWEB.COM>
  3. To: BUGTRAQ@netspace.org
  4. Subject: Tetrix 1.13.16 is Vulnerable
  5.  
  6.    I have recently found a buffer overflow in a TetriNet daemon for Linux
  7. called "Tetrix". To exploit this bug, you will need a hostname longer than
  8. 122 characters, and any method of connecting to the host on port 31457.
  9. Once you are connected, the overflow should take place.
  10.  
  11. here is the patch!
  12.  
  13.  
  14. ----------------------------------snip snip-------------------------------
  15. diff -ru tetrinetx-1.13.16.orig/src/main.c tetrinetx-1.13.16/src/main.c
  16. --- tetrinetx-1.13.16.orig/src/main.c   Thu Dec 24 00:24:50 1998
  17. +++ tetrinetx-1.13.16/src/main.c        Sun Feb 14 16:22:45 1999
  18. @@ -2561,7 +2562,7 @@
  19.  /* Someone has just connected. So lets answer them */
  20.  void net_telnet(struct net_t *n, char *buf)
  21.    {
  22. -    unsigned long ip; int k,l; char s[121]; char strg[121];
  23. +    unsigned long ip; int k,l; char s[UHOSTLEN]; char strg[121];
  24.      char n1[4], n2[4], n3[4], n4[4];
  25.      struct channel_t *chan, *ochan;
  26.      struct net_t *net;
  27. diff -ru tetrinetx-1.13.16.orig/src/main.h tetrinetx-1.13.16/src/main.h
  28. --- tetrinetx-1.13.16.orig/src/main.h   Thu Dec 24 00:24:50 1998
  29. +++ tetrinetx-1.13.16/src/main.h        Sun Feb 14 16:19:06 1999
  30. @@ -48,9 +48,8 @@
  31.  #define SERVERBUILD "16"               /* What build we are at */
  32.  #define NICKLEN 30                     /* Maximum length of Nickname */
  33.  #define VERLEN 10                      /* Maximum length of Tetrinet version */
  34. -#define UHOSTLEN 30                    /* Maximum length of Hostname */
  35. +#define UHOSTLEN 256                   /* Maximum length of Hostname */
  36.  #define TEAMLEN NICKLEN                        /* Maximum length of teamname */
  37. -/*#define MAXNET 80*/                  /* Maximum network sockets */
  38.  #define MAXWINLIST 100                 /* Maximum entries on Winlist */
  39.  #define TELNET_PORT 31457              /* Telnet port to listen on */
  40.  #define QUERY_PORT 31456               /* Query port to listen on */
  41. diff -ru tetrinetx-1.13.16.orig/src/net.c tetrinetx-1.13.16/src/net.c
  42. --- tetrinetx-1.13.16.orig/src/net.c    Thu Dec 24 00:24:50 1998
  43. +++ tetrinetx-1.13.16/src/net.c Sun Feb 14 16:22:11 1999
  44. @@ -250,15 +250,17 @@
  45.  unsigned long ip;
  46.  {
  47.    struct hostent *hp; unsigned long addr=ip;
  48. -  unsigned char *p; static char s[121];
  49. -/*  alarm(10);*/
  50. +  unsigned char *p; static char s[UHOSTLEN];
  51. +
  52.    hp=gethostbyaddr((char *)&addr,sizeof(addr),AF_INET); /*alarm(0);*/
  53.    if (hp==NULL) {
  54.      p=(unsigned char *)&addr;
  55.      sprintf(s,"%u.%u.%u.%u",p[0],p[1],p[2],p[3]);
  56.      return s;
  57.    }
  58. -  strcpy(s,hp->h_name); return s;
  59. +  strncpy(s,hp->h_name,(UHOSTLEN-1));
  60. +  s[strlen(s)]='\0';
  61. +  return s;
  62.  }
  63.  
  64.  /* short routine to answer a connect received on a socket made previously
  65. ----------------------------------snip snip-------------------------------
  66.  
  67.